/*
 * SonarQube
 * Copyright (C) 2009-2017 SonarSource SA
 * mailto:info AT sonarsource DOT com
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
@import (reference) "../mixins";
@import (reference) "../variables";
@import (reference) "../init/type";
@import (reference) "ui";

@source-line-height: 18px;
@lineWithIssuesBackground: #ffeaea;
@duplicationColor: #f3ca8e;

.source-viewer {
  width: 100%;
  min-height: 200px;
  border: 1px solid @barBorderColor;
  box-sizing: border-box;
  background-color: #fff;
  overflow-x: auto;
  overflow-y: hidden;
}

.source-table {
  width: 100%;
  border: none;
  border-collapse: collapse;
}

.source-line:hover {
  .source-line-number,
  .source-line-issues,
  .source-line-coverage,
  .source-line-duplications,
  .source-line-duplications-extra,
  .source-line-filtered-container,
  .source-line-scm {
    border-color: darken(@barBackgroundColor, 4%);
    background-color: darken(@barBackgroundColor, 4%);
  }

  .source-line-code {
    background-color: darken(#fff, 4%);
  }
}

.source-line-highlighted,
.source-line-highlighted:hover {
  .source-line-number,
  .source-line-issues,
  .source-line-coverage,
  .source-line-duplications,
  .source-line-duplications-extra,
  .source-line-filtered-container,
  .source-line-scm {
    border-color: #fdf190 !important;
    background-color: #fdf190;
  }

  .source-line-code {
    background-color: #fff8c2;
  }
}

.source-line-shadowed {
  .source-line-code {
    background-color: #f9f9f9;
  }
}

.source-line-filtered {
  .source-line-filtered-container {
    background-color: @blue !important;
  }
}

.source-line-last .source-line-code-inner {
  padding-bottom: 80px;
}

.source-viewer pre {
  height: @source-line-height;
  padding: 0;
}

.source-viewer pre,
.source-meta {
  line-height: @source-line-height;
  font-family: @monoFontFamily;
  font-size: 12px;
}

.source-line-code {
  position: relative;
  padding: 0 10px;

  pre {
    float: left;
  }

  .issue-list {
    margin-left: -10px;
    margin-right: -10px;
  }
}

.source-line-code-inner {
  .clearfix;
}

.source-line-code-issue {
  display: inline-block;
  background-image: url();
  background-repeat: repeat-x;
  background-size: 4px;
  background-position: bottom;
}

.source-meta {
  vertical-align: top;
  width: 1px;
  background-clip: padding-box;
  user-select: none;
}

.source-meta:focus {
  outline: none;
}

.source-meta[role="button"] {
  cursor: pointer;
}

.source-meta + .source-meta {
  border-left: 1px solid @barBackgroundColor;
}

.source-line-number {
  min-width: 18px;
  padding: 0 10px;
  background-color: @barBackgroundColor;
  color: @secondFontColor;
  text-align: right;

  &:before {
    content: attr(data-line-number);
  }
}

.source-line-issues {
  position: relative;
  padding: 0 2px;
  background-color: @barBackgroundColor;
}

.source-line-issues-counter {
  position: absolute;
  top: -1px;
  right: -1px;
  line-height: 8px;
  font-size: 8px;
}

.source-line-coverage {
  background-color: @barBackgroundColor;
}

.source-line-duplications,
.source-line-duplications-extra {
  background-color: @barBackgroundColor;
}

.source-line-duplications-extra {
  display: none;
}

.source-duplications-expanded {
  .source-line-duplications {
    display: none;
  }

  .source-line-duplications-extra {
    display: table-cell;
  }
}

.source-line-filtered-container {
  background-color: @barBackgroundColor;
}

.source-line-scm {
  padding: 0 5px;
  background-color: @barBackgroundColor;
}

.source-line-scm-inner {
  max-width: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  &:before {
    content: attr(data-author);
  }
}

.source-line-bar {
  width: 5px;
  height: @source-line-height;
}

.source-line-covered {
  background-color: @green !important;
}

.source-line-uncovered {
  background-color: @red !important;
}

.source-line-partially-covered {
  background-color: @orange !important;
  background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, .5) 4px, transparent 4px, transparent 8px, rgba(255, 255, 255, .5) 8px, rgba(255, 255, 255, .5) 12px, transparent 12px, transparent 16px, rgba(255, 255, 255, .5) 16px, rgba(255, 255, 255, .5) 20px) !important;
}

.source-line-duplicated {
  background-color: @duplicationColor !important;
}


// Header

.source-viewer-header {
  .clearfix;
  position: relative;
  padding: 2px 10px 4px;
  border-bottom: 1px solid @barBorderColor;
  background-color: @barBackgroundColor;
}

.source-viewer-header-bar + .source-viewer-header-bar {
  border-top: 1px solid @barBorderColor;
}

.source-viewer-header-component {
  float: left;
  padding-top: 4px;
}

.source-viewer-header-component-project {
  color: #777;
  font-size: @smallFontSize;
}

.source-viewer-header-component-name {
  font-weight: 600;
}

.source-viewer-header-favorite {
  position: relative;
  top: -2px;
  margin-left: 4px;
  .link-no-underline;
}

.source-viewer-header-measures {
  float: right;
}

.source-viewer-header-measures-scope {
  position: relative;
  float: left;
}

.source-viewer-header-measure {
  display: inline-block;
  vertical-align: middle;
  padding: 3px 0;
  font-size: @baseFontSize;

  .rating {
    font-size: 18px;
  }
}

.source-viewer-header-measure + .source-viewer-header-measure {
  margin-left: 25px;
}

.source-viewer-header-measure-label {
  display: block;
  margin-top: 4px;
  line-height: @smallFontSize;
  color: #777;
  font-size: @smallFontSize;
}

.source-viewer-header-measure-value {
  display: block;
  line-height: 18px;
  color: @baseFontColor;
  font-size: 18px;
  font-weight: 300;
}

.source-viewer-header-external-link {
  .link-no-underline;

  i {
    position: relative;
    top: -4px;
  }
}

.source-viewer-header-actions {
  float: right;
  display: block;
  margin-left: 25px;
  padding: 13px 5px;
}

.source-viewer-header-more-actions {
  position: absolute;
  z-index: @dropdown-menu-z-index;
  right: 0;
  top: 100%;
  padding: 10px;
  border: 1px solid @barBorderColor;
  border-right: none;
  background-color: @white;
  line-height: 1.8;
}

.source-viewer-measures-overlay {
  width: 1100px;
  left: 50%;
  right: auto;
  margin-left: -550px;
  padding: 20px 10px;
  background-color: @barBackgroundColor;

  .modal-foot {
    width: 1100px;
    left: 50%;
    right: auto;
    margin-left: -550px;
  }
}

.source-viewer-measures-component {
  float: none;
  margin: 0 10px 30px;
}

.source-viewer-measures-modal {
  background-color: @barBackgroundColor;
}

.source-viewer-measures {
  .clearfix;
  margin: 0 -10px;
  background-color: @barBackgroundColor;

  .bubble-popup-section {
    width: 100%;
  }
}

.source-viewer-measures + .source-viewer-measures {
  margin-top: 40px;
}

.source-viewer-measures-secondary .source-viewer-measures-card {
  background-color: fade(#fff, 60%);
}

.source-viewer-measures-section {
  float: left;
  width: 25%;
  margin: -20px 0;
}

.source-viewer-measures-section-big {
  width: 50%;
}

.source-viewer-measures-section-full {
  width: 100%;
}

.source-viewer-measures-section + .source-viewer-measures-section-full {
  margin-top: 20px;
}

.source-viewer-measures-card {
  margin: 20px 10px;
  padding: 10px;
  border: 1px solid @barBorderColor;
  background-color: #fff;
}

.source-viewer-measures-card-overflow {
  overflow: auto;
}

.source-viewer-measures-card-fixed-height {
  max-height: 36vh;
  overflow-y: scroll;
}


//.source-viewer-measures-section + .source-viewer-measures-section {
//  border-left: 1px solid @barBorderColor;
//}

.source-viewer-tests-list {
  width: 100%;
  font-size: @baseFontSize;
}

.source-viewer-test-status,
.source-viewer-test-duration,
.source-viewer-test-covered-lines {
  width: 1px;
}

.source-viewer-test-status,
.source-viewer-test-duration,
.source-viewer-test-covered-lines,
.source-viewer-test-covered-name {
  vertical-align: middle;
  padding: 3px;
}

.source-viewer-test-name {
  padding-left: 10px;
  word-break: break-all;
}

.source-viewer-test-covered-lines {
  text-align: right;
}

.source-viewer-issue-location {
  max-width: 200px;
  margin-right: 10px;
  .text-ellipsis;
}

.source-viewer-flow-location + .source-viewer-flow-location {
  z-index: @issue-flow-location-z-index - 1;
}

.source-line-issue-locations {
  float: right;
  margin-right: -10px;

  &:empty {
    display: none;
  }
}

.source-viewer-more-code {
  padding: 40px 0;
  border-bottom: 1px solid @barBorderColor;
  background-color: @barBackgroundColor;
  text-align: center;

  .spinner {
    top: -1px;
  }

  .source-table + & {
    border-bottom: none;
    border-top: 1px solid @barBorderColor;
  }
}
